﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VonaJobs.BLL;
using VonaJobs.DAL.DAO;
using VonaJobs.DAL.Gatway;

namespace VonaJobs.UI.Admin
{
    public partial class CreateMembershipType : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void SaveMembershipType(object sender, EventArgs e)
        {
            try
            {
                MemberType memberType = new MemberType();
                MemberTypeManager memberTypeManager = new MemberTypeManager();
                memberType.TypeName = txtMembershipName.Value;
                string msg = memberTypeManager.SaveMemberType(memberType);
                PopulateMemberShipType();
                msgLbl.Text = msg;
                msgLbl.ForeColor = Color.Green;

            }
            catch (Exception)
            {

                new Exception("Error occured when save member ship type");
            }
        }
        public void UpdateMembershipType(object sender, EventArgs eventArgs)
        {

            try
            {
                MemberType memberType = new MemberType();
                MemberTypeManager memberTypeManager = new MemberTypeManager();
                memberType.TypeName = txtMembershipName.Value;
                string msg = memberTypeManager.UpdateMemberType(memberType);
                msgLbl.Text = msg;
                msgLbl.ForeColor = Color.Green;

            }
            catch (Exception)
            {

                new Exception("Error occured when updating membership type");
            }
        }


        public void PopulateMemberShipType()
        {
            MemberTypeManager manager = new MemberTypeManager();
            List<MemberType> memberTypes = new List<MemberType>();
            memberTypes = manager.GetAllMemberType();
            gdvMemberType.DataSource = memberTypes;
            gdvMemberType.DataBind();

        }
    }
}